package com.travelranking.rest;

import java.util.ArrayList;
import java.util.List;

import com.travelranking.pojo.City;
import com.travelranking.pojo.Travel;
import com.travelranking.service.RankingService;

public class RestListTravelServiceImpl implements RestListTravelService {
	
	private RankingService service;
	
	@Override
	public List<TravelWrapper> list() {
		List<TravelWrapper> result = new ArrayList<TravelWrapper>(); 
		for (Travel t :service.list()){
			TravelWrapper w = new TravelWrapper();
			w.setId(t.getId());
			w.setOpinion(t.getOpinion());
			w.setCity(t.getCity());
			w.setRank(t.getRank());
			result.add(w);
		}

		return result;
	}

	public RankingService getService() {
		return service;
	}

	public void setService(RankingService service) {
		this.service = service;
	}

	
	@Override
	public TravelWrapper getTravel(Long id) {
		TravelWrapper tw = new TravelWrapper();
		tw.setCity(new City());
		tw.setId(1000L);
		return tw;
	}

	@Override
	public void add(City city, String opinion, Integer rank) {
		Travel t = new Travel();
		t.setCity(city);
		t.setOpinion(opinion);
		t.setRank(rank);
		
		service.add(t);
		
	}

	@Override
	public void addObjeto(City city, String opinion, Integer rank) {
		Travel t = new Travel();
		t.setCity(city);
		t.setOpinion(opinion);
		t.setRank(rank);
		
		service.add(t);
		
	}

	
	
}
